# Maintainer: Tim Meusel <tim@bastelfreak.de>
# Contributor: Artem Vorotnikov <artem@vorotnikov.me>
# Contributor: Tim Meusel <tim@bastelfreak.de>
# Contributor: Mario Finelli <mario at finel dot li>

_gemname='minitar'
pkgname="ruby-${_gemname}"
pkgver=0.9
pkgrel=3
pkgdesc='A pure-Ruby library that provides the ability to deal with POSIX tar(1) archive files'
arch=('any')
url='https://github.com/halostatue/minitar/'
license=('RUBY' 'BSD')
makedepends=('ruby-rdoc' 'ruby-rake' 'ruby-hoe' 'ruby-minitest')
depends=('ruby')
source=("https://github.com/halostatue/minitar/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.gz")
options=("!emptydirs")
sha512sums=('e3aaf0e664a985704cf9dccb72250ea2a7ebb2db9b6120590fb8d5525fe2717e0a90b3020f461ae0c4dfb19dc8728b4eeb6ba2e24ab75d12fbd7f5d98b269c79')

# update the gemspec to allow newer versions of rake
# remove references to cloud CI pipelines (they require more gems and don't bring any value)
prepare() {
  cd "${_gemname}-${pkgver}"
  sed --in-place 's|~>|>=|g' "${_gemname}.gemspec"
  sed --in-place "/Rake::Task\['travis'\].*/d" Rakefile
}

build() {
  cd "${_gemname}-${pkgver}"
  #gem build "${_gemname}.gemspec"
  rake gem
}

check() {
  cd "${_gemname}-${pkgver}"
  rake test
}

package() {
  cd "${_gemname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "pkg/${_gemname}-${pkgver}.gem"

  install -Dm 644 Licence.md -t "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}

# vim: ts=2 sw=2 et:
